/**
 * BigChar.java
 *
 * Provider: CoderDream's Studio
 *
 * History
 *	Date(DD/MM/YYYY)    Author          Description
 * ----------------------------------------------------------------------------
 *	Oct 31, 2007		CoderDream		Created
 */
package com.coderdream.chapter20.flyweight.sample;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

/**
 * @author XL
 * 
 */
public class BigChar {
	// 字符名称
	private char charname;
	// 输出成大型字符的字符串(有'#' '.' '\n'的行)
	private String fontdata;

	/**
	 * 构造函数
	 * 
	 * @param charname
	 */
	public BigChar(char charname) {
		this.charname = charname;
		try {
			File file = new File("");
			String s = file.getAbsolutePath();
			BufferedReader reader = new BufferedReader(new FileReader(s
					+ "\\src\\com\\coderdream\\chapter20"
					+ "\\flyweight\\sample\\big" + charname + ".txt"));
			String line;
			StringBuffer buf = new StringBuffer();
			while ((line = reader.readLine()) != null) {
				buf.append(line);
				buf.append("\n");
			}

			reader.close();
			this.fontdata = buf.toString();
		} catch (IOException e) {
			this.fontdata = charname + "?";
		}
	}

	/**
	 * 输出大型字符
	 */
	public void print() {
		System.out.print(fontdata);
	}
}
